import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 邓大帅
 * Date: 2024-01-09
 * Time: 9:19
 */
public class Test1 {
    public static void main(String[] args){
//        Java中二维数组的每一行数组元素个数可以不同
        int[][] array1 = new int[2][];
//        若是不赋值，array元素引用为null
        array1[0] = new int[2];
        array1[1] = new int[4];
    }
    public static void main1(String[] args) {
//        二维数组的三种定义方式
        int[][] array1 = {{1,2,3},{4,5,6}};
        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};
        int[][] array3 = new int[2][3];
//        二维数组实际上是一个一维数组，数组元素为每一行数组的引用
//        二维数组的遍历
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println("==========");
        for (int[] ret : array1) {
            for (int x : ret) {
                System.out.print(x + " ");
            }
            System.out.println();
        }
        System.out.println("==========");
        System.out.println(Arrays.deepToString(array1));
    }
}
